//
//  YCommentView.m
//  yuimall_Iphone
//
//  Created by yuike6 yuike6 on 12-4-14.
//  Copyright (c) 2012年 yuike. All rights reserved.
//

#import "YCommentView.h"
#import "header.h"

@implementation YCommentView
@synthesize commentData = commentData_;

@synthesize userView = userView_;
@synthesize bodyView = bodyView_;


-(void) dealloc
{
    YRelease(commentData_);
    
    YRelease(userView_)
    YRelease(bodyView_)
    
    [super dealloc];
}


-(void) setCommentData:(YCommentModel *)commentDataValue
{
    YRelease(commentData_)
    commentData_ = [commentDataValue retain];
    
    [self.userView setCommentData:commentDataValue];
    [self.bodyView setCommentData:commentDataValue];
}

-(void) privateInit
{
    if (self.bInited) 
    {
        return;
    }
    
    YCommentUserView * tmp_userview = [[YCommentUserView alloc] init];
    self.userView = tmp_userview;
    YRelease(tmp_userview);
    [self addSubview:self.userView];
    
    YCommentBodyView * tmp_bodyview = [[YCommentBodyView alloc] init];
    self.bodyView = tmp_bodyview;
    YRelease(tmp_bodyview);
    [self addSubview:self.bodyView];
    
    [self reAdjustLayout];
    self.bInited = TRUE;
}


-(id) init
{
    self = [super init];
    if (self) {
        [self privateInit];
    }
    return self;
}


- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) 
    {
        // Initialization code
        [self privateInit];
    }
    return self;
}


-(void) reAdjustLayout
{
    [self.userView setFrame:CGRectMake(3, 3, self.width / 5, self.height - 6)];
    
    CGFloat origin_x = self.userView.origin_x + self.userView.width + 10;
    [self.bodyView setFrame:CGRectMake(origin_x, 
                                       3, 
                                       self.width - (origin_x + 10), 
                                       self.height - 6)];
    
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/

@end
